class PSKismetGFXIntel extends SequenceAction;

struct TextAndTime
{
	var() string Title;
	var() array<string> Text;
	var() float Time;
};

var() bool bSmallIntel;
var() TextAndTime TextoES;
var() TextAndTime TextoEN;

var PSPlayerController pc;

event Activated()
{
	local int idioma;

	if (InputLinks[0].bHasImpulse)
	{
		pc = none;

		if (Targets.length == 0)
		{
			`Log("WARNING: No Target for Subtitle DisplayText");
		}
		else
		{
			if(Targets[0].IsA('PSPlayerController'))
			{
				pc = PSPlayerController(Targets[0]);
			}
			else if(Targets[0].IsA('PSPawnDidrik'))
			{
				pc = PSPlayerController(PSPawnDidrik(Targets[0]).Controller);
			}


			if(pc==none) return;

			idioma = PSGameInfo(pc.WorldInfo.Game).subtitleLang;

			if(idioma==2)  pc.PSPlayIntel(TextoEN.Title, getFinalText(TextoEN), TextoEN.Time, bSmallIntel);
			else           pc.PSPlayIntel(TextoES.Title, getFinalText(TextoES), TextoES.Time, bSmallIntel);
		}
	}
	else
	{
		if(pc!=none) pc.PSCloseIntel();
	}
}

function string getFinalText(TextAndTime text)
{
	local string txtRes;
	local int i;

	txtRes = "";
	
	for(i=0; i<text.Text.Length; i++)
	{
		txtRes = txtRes $ text.Text[i] $ "\n";
	}

	return txtRes;
}

DefaultProperties
{
	ObjName="PSKismetGFXIntel"
	ObjCategory="PS Actions"

	InputLinks(0)=(LinkDesc="Start")
	InputLInks(1)=(LinkDesc="Stop")

	bSmallIntel = false;
}
